<%@page import="java.util.List"%>
<%@page import="com.gkwave.module.bean.LocationBean"%>
<%@page import="com.gkwave.module.dao.HealthCareDAO"%>
<%@page import="java.util.Iterator"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>::HeaderPage::</title>
<script type="text/javascript">
function _validate(action){
	document.forms["bloodBank"]._hidden.value = action;
	return;
}
</script>

</head>
<%
String action = (String)request.getParameter("_hidden");
System.out.println(action);
boolean result = false;
boolean isSubmitted = false;
if(action!= null && action.equals("save")){
	String nmBloodGroup = (String)request.getParameter("nmBloodGroup");
	String nrUnitRequired = (String)request.getParameter("nrUnitRequired");
	String nmPatient = (String)request.getParameter("nmPatient");
	String nmHospital = (String)request.getParameter("nmHospital");
	String idLocation = (String)request.getParameter("idLocation");
	String idPatient = (String)request.getParameter("idPatient");
	String nmContact = (String)request.getParameter("nmContact");
	String dtDate = (String)request.getParameter("dtDate");
	String tsTiming = (String)request.getParameter("tsTiming");
	String txtDescroption = (String)request.getParameter("txtDescroption");
	
	HealthCareDAO dao = new HealthCareDAO();
	result = dao.saveBloodDetail(nmBloodGroup,nrUnitRequired,nmPatient,nmHospital,idLocation,idPatient,nmContact,dtDate,tsTiming,txtDescroption);
	isSubmitted = true;
}
HealthCareDAO dao = new HealthCareDAO();
List<LocationBean> list = dao.getLocationList();
%>

<body>
<form name="bloodBank" action="bloodBank" method="post">
<input type="hidden" name="_hidden">
	<table>
		<thead>Blood Requirement Page</thead>
		<%
		if(isSubmitted){
			if(result){
		%>
			<tr align="center">
				<td align="center" colspan="2">Data saved successfully!!!</td>
			</tr>
		<%
			}else{
		%>
			<tr align="center">
				<td align="center" colspan="2">Error...!!!</td>
			</tr>
		<%
			}
		}
		%>
		<tr>	
			<td>Location</td>
			<td>
				<select name="idLocation">
					<option value="0">--Select--</option>
				<%
					if(list!=null){
						Iterator ite = list.iterator();
						while(ite.hasNext()){
						LocationBean bean = (LocationBean)ite.next();
						Integer id = bean.getIdLocation();
						String name = bean.getNmLocation();
				%>
					<option value='<%=id%>'><%=name%></option>
				<%
						}
					}
				%>
				</select>
			</td>
		</tr>		
		<tr>
			<td>Blood Group</td><td><input type="text" name="nmBloodGroup" size="2" maxlength="5"></td>
		</tr>
		<tr>	
			<td>Required Unit</td><td><input type="text" name="nrUnitRequired" size="2" maxlength="3"></td>
		</tr>
		<tr>	
			<td>Patient Name</td><td><input type="text" name="nmPatient"></td>
		</tr>	
		<tr>
			<td>Hospital Name</td><td><input type="text" name="nmHospital"></td>
		</tr>
		<tr>	
			<td>Patient ID</td><td><input type="text" name="idPatient"></td>
		</tr>	
		<tr>
			<td>Contact number</td><td><input type="text" name="nmContact"></td>
		</tr>
		<tr>	
			<td>Date </td><td><input type="text" name="dtDate" size="6" maxlength="10">(yyyy-mm-dd)&nbsp;&nbsp;Time <input type="text" name="tsTiming" size="8" maxlength="8">(hh:mm:ss)</td>
		</tr>	
		<tr>	
			<td>Description</td><td><textarea rows="10" name="txtDescroption" cols="35"></textarea></td>
		</tr>
		<tr>
			<td><input type="submit" onclick="_validate('save')" value="Save"></td><td><input type="reset" value="Reset"></td>
		</tr>
	</table>
</form>
</body>
</html>